package Test;

import dao.UserDao;
import dao.teaDao;
import entity.User;
import entity.category;
import entity.tea;
import org.apache.ibatis.session.SqlSession;
import util.MyBatisUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class UserTest {
    public static void main(String[] args) {
        SqlSession sqlSession = MyBatisUtils.openSession();
        UserDao mapper = sqlSession.getMapper(UserDao.class);
        User user = mapper.findUser();
        System.out.println(user);
    }
}
class teaDao1{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        mapper.insert(new tea(1,"金桔柠檬",2,"",3));
        session.commit();
    }
}
class teaDao2{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        mapper.update(new tea(15,"ssss",5,"",4));
        session.commit();
    }
}
class teaDao3{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        mapper.delete(15);
        session.commit();
    }
}
class teaDao4{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        List<tea> teas = mapper.findAll(1, 4, "");
        System.out.println(teas);
        session.commit();
    }
}
class teaDao5{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        int teas = mapper.count("红");
        System.out.println(teas);
        session.commit();
    }
}
class teaDao6{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        List<category> cate = mapper.findCate();
        System.out.println(cate);
        session.commit();
    }
}
class teaDao7{
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.openSession();
        teaDao mapper = session.getMapper(teaDao.class);
        tea findone = mapper.findone(19);
        System.out.println(findone);
        session.commit();
    }
}